﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TPCN.DAL;

namespace TPCN.Controls
{
    public partial class uc_supportonline : System.Web.UI.UserControl
    {
        private static List<SupportOnlineObj> source;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadDataToList();
                htmlcode.Text = GenarateHtmlCode();
            }
        }

        protected void LoadDataToList()
        {
            source = new List<SupportOnlineObj>();
            source = SupportOnlineDAL.GetByAll();
        }

        protected string GenarateHtmlCode()
        {
            string html = String.Empty;
            if (source.Count > 0)
            {
                foreach (SupportOnlineObj i in source)
                {
                    html += "<div class=\"supportonline\"><a href=\"ymsgr:sendim?";
                    html += i.Nickname.Trim();
                    html += "\"><img src=\"http://opi.yahoo.com/online?u=";
                    html += i.Nickname.Trim();
                    html += "&m=g&t=2\" alt=\"Gửi tin nhắn tới ";
                    html += i.Name.Trim();
                    html += "\" /></a>";
                    html += "<br />";
                    html += i.Name;
                    html += "</div>";
                    html += Environment.NewLine;
                }
                html += "</ul>";
            }
            return html;
        }
    }
}